#!/bin/bash
#remove pre-existing version of the systemctl service
systemctl stop uav_configurator
systemctl disable uav_configurator
rm /etc/systemd/system/uav_configurator.service
systemctl daemon-reload
systemctl reset-failed

#setup new systemctl service
touch /etc/systemd/system/uav_configurator.service
> /etc/systemd/system/uav_configurator.service
echo "[Unit]
Description=MRS UAV USB Configurator service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/etc/ctu-mrs/usb-configurator-triggers/configurator.sh
[Install]
WantedBy=multi-user.target" >> /etc/systemd/system/uav_configurator.service
systemctl daemon-reload
systemctl enable uav_configurator
systemctl start uav_configurator
